package org.apache.rocketmq.example.quickstart.filter;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.example.quickstart.base.BaseProducer;

import java.util.Arrays;
import java.util.List;

/**
 * tag过滤生产者
 */
public class TagFilterProducer {

    public static void main(String[] args) throws MQClientException {
        DefaultMQProducer producer = new BaseProducer().getInstance();
        producer.start();

        List<String> list = Arrays.asList("tagA", "tagB", "tagC");
        for (String tag : list) {
            Message message = new Message("topic-8", tag, ("message-" + tag).getBytes());

            try {
                SendResult send = producer.send(message);
                System.out.println(send);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        producer.shutdown();
    }
}
